package com.github.yoojia.flow.at;

import com.github.yoojia.flow.util.JSONSerializer;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 2017 Yoojia Chen (yoojiachen@gmail.com)
 */
public class ATEvents {

    private ATEvents() {
    }

    public static final int CODE_ERROR = 0;
    public static final int CODE_SUCCESS = 1;

    public static final String AT_SYS_TOPIC = "AT_SYS";
    public static final String AT_SYS_ADDRESS = "@AT_COMMAND_SYS";

    static final String AT = "AT+";
    static final String CMD_MEM = "MEM";
    static final String CMD_CPU = "CPU";
    static final String CMD_VER = "VER";
    static final String CMD_DEV = "DEV";

    static String success(Map<String, Object> data) {
        data.put("success", CODE_SUCCESS);
        return JSONSerializer.mapToJSONText(data);
    }

    static String error(String message) {
        Map<String, Object> data = new HashMap<>(2);
        data.put("success", CODE_ERROR);
        data.put("msg", message);
        return JSONSerializer.mapToJSONText(data);
    }
}
